clear *

use "${root}/data/processed/final_sample.dta", clear


keep margin_mayor_left *_sample lame_duck
set scheme plotplain

* Baseline sample
keep if baseline_sample == 1

rddensity margin_mayor_left, c(0) plot  ///
graph_opt(xtitle("Left margin of victory") legend(off position(6)) ///
graphr(c(white)))
graph export "${root}/results/figures/manipulation_test_mayor_left.pdf", as(pdf) replace

* Lame-duck subsample

rddensity margin_mayor_left if lame_duck == 1, c(0) plot ///
graph_opt(xtitle("Left margin of victory") legend(off position(6)) ///
graphr(c(white)) name(lame_duck) title("Lame-ducks"))

* Tiebout median subsample

rddensity margin_mayor_left if tiebout_median_sample == 1, c(0) plot   ///
graph_opt(xtitle("Left margin of victory") legend(off position(6)) ///
graphr(c(white)) name(tiebout_median) title("Tiebout<median"))

* Coalition distance subsample

rddensity margin_mayor_left if coal_dist_median_sample == 1, c(0) plot  ///
graph_opt(xtitle("Left margin of victory") legend(off position(6)) ///
graphr(c(white)) name(coal_dist) title("Ideology distance>median"))

* Oil-windfalls subsample

rddensity margin_mayor_left if oil_sample == 1, c(0) plot   ///
graph_opt(xtitle("Left margin of victory") legend(off position(6)) ///
graphr(c(white)) name(oil) title("Oil windfall"))

graph combine lame_duck tiebout_median coal_dist oil, xcommon row(2) cols(2) b1(Left margin of victory)
graph export "${root}/results/figures/manipulation_tests_subsamples.pdf", replace
